#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import time

def bar(num, total):
    rate = num / total
    rate_num = int(rate * 100)
    # \r表示回车; "=" * num 表示完成的进度 ; "*"*(100-num)表示还剩好多进度; rate_num表示后面的进度值
    r = '\r[%s%s]%d%%' %("=" * num, "*"*(100-num), rate_num, )
    # 将内容打印到控制台
    sys.stdout.write(r)
    # print(r)
    sys.stdout.flush()

if __name__ == '__main__':
    for i in range(0, 101):
        time.sleep(0.1)
        bar(i, 100)